package com.atlzk.renting.order.controller;

import com.atlzk.common.entity.order.LeaseOrderEntity;
import com.atlzk.common.utils.PageUtils;
import com.atlzk.common.utils.R;
import com.atlzk.renting.order.service.LeaseOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;


/**
 * @author liuzekun
 * @email 2803587841@gmail.com
 * @date 2021-07-16 20:02:47
 */
@RestController
@RequestMapping("order/leaseorder")
public class LeaseOrderController {
    @Autowired
    private LeaseOrderService leaseOrderService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("order:leaseorder:list")
    public R list(@RequestParam Map <String, Object> params) {
        PageUtils page = leaseOrderService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("order:leaseorder:info")
    public R info(@PathVariable("id") Long id) {
        LeaseOrderEntity leaseOrder = leaseOrderService.getById(id);

        return R.ok().put("leaseOrder", leaseOrder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("order:leaseorder:save")
    public R save(@RequestBody LeaseOrderEntity leaseOrder) {
        leaseOrderService.save(leaseOrder);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("order:leaseorder:update")
    public R update(@RequestBody LeaseOrderEntity leaseOrder) {
        leaseOrderService.updateById(leaseOrder);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("order:leaseorder:delete")
    public R delete(@RequestBody Long[] ids) {
        leaseOrderService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }


}
